<?php
use yii\widgets\LinkPager;
use yii\web\Session;
use app\modules\cruise\models\Member;

$this->title = '统计';

$member = \Yii::$app->session->get('member');

$member_model = Member::find()->where(['phone'=>$member['phone'],'status'=>1])->one();

$role = $member_model['role'];

?>

<?= yii\web\View::registerCssFile("/m/css/reset.css",['depends' => 'app\assets\MuiAsset']) ?>
<?= yii\web\View::registerCssFile("/m/css/bootstrap.min.css",['depends' => 'app\assets\MuiAsset']) ?>
<?= yii\web\View::registerCssFile("/m/css/app.css",['depends' => 'app\assets\MuiAsset']) ?>
<?= yii\web\View::registerCssFile("/m/css/tongji.css",['depends' => 'app\assets\MuiAsset']) ?>

<style type="text/css">
	#myModal1{padding-left: 20px !important;}
    .edit{height: 40px;text-align: center;background-color: #19a58e;}
    .th span{
        display: inline-block;
        /*width: 45px;*/
        height: 25px;
        font-size: 12px;
        border-radius: 5px;
        border: 1px solid #e6e6e6;
        line-height: 25px;
        margin-bottom: 5px;
        text-align: center;
        padding: 0 10px;
    }
</style>

<input type="hidden" name="_csrf" id="_csrf" value="<?=\Yii::$app->getRequest()->getCsrfToken()?>">

<div class="nav mui-row">
    <?php if($role == 3){ ?>
        <div class="qiandao mui-col-sm-4 mui-col-xs-4">
            <a href="/sign/sign/index">签到</a>
        </div>
        <div class="tongji mui-col-sm-4 mui-col-xs-4">
            <a>统计</a>
        </div>
        <div class="edit mui-col-sm-4 mui-col-xs-4">
            <a href="/sign/sign/cancel-list">审核</a>
        </div>
    <?php }else{ ?>
		<div class="qiandao mui-col-sm-6 mui-col-xs-6">
			<a href="/sign/sign/index">签到</a>
		</div>
		<div class="tongji mui-col-sm-6 mui-col-xs-6">
			<a>统计</a>
		</div>
    <?php }?>
</div>
<div class="biaoti mui-row">
	<div class="logo mui-col-xs-3 mui-col-sm-3">
		<img src="/img/logo.png"/>
	</div>
	<div class="chaxun mui-col-xs-9 mui-col-sm-9">
		<form action="/sign/sign/statis" method="post" id="statis">
			<input type="hidden" name="_csrf" id="_csrf" value="<?=Yii::$app->getRequest()->getCsrfToken()?>">
			<input onfocus="this.blur();" type="text" name="group_tag" id="tm" value="<?=$group_tag?>" placeholder="团号"/>
		</form>	
	</div>
</div>

<div class="tubiao" style="padding-left: 5%">
	<div id="t1" class="mui-col-xs-11"></div>
</div>


<nav class="mui-bar mui-bar-tab">
    <button class="foot">查看详情</button>
</nav>

<div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" style="padding-top: 15px;">
          <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <span>选择团号</span>
                    <span class="quanxuan">全选<input type="checkbox" name="xz"/></span>
                </div>
                <div>
                    <p class="mui-row group_tag th">
                     <?php if($group_arr){ ?>
                        <?php foreach ($group_arr as $key=>$value){ ?>
                                <span data-id="<?=$value?>" <?=(in_array($value,$group_tag_arr) ? 'class="act"' : '' )?>><?=$value?></span>
                        <?php }?>
                     <?php }?>  
                    </p>

                    <p class="mui-row" style="float: right;margin-right: 20px;">
                         <button type="button" class="mui-btn mui-btn-primary" id="submit">确定</button>
                    </p>        
                </div>
            </div>
          </div>
</div>


<?= yii\web\View::registerJsFile("/m/js/bootstrap.min.js",['depends' => 'app\assets\MuiAsset']) ?>
<?= yii\web\View::registerJsFile("/m/js/echarts.min.js",['depends' => 'app\assets\MuiAsset']) ?>

<?php app\components\JsBlock::begin() ?>
<script type="text/javascript">

var phone = $.trim(localStorage.getItem("phone"));
var _csrf = $("#_csrf").val();
 if(phone.length != 0){
    $.ajax({
       type: "post",
       async:false, 
       url: "/sign/member/auto-login",
       data: {'phone':phone,'_csrf':_csrf},
       success: function(res){
            var res = $.parseJSON(res);
            if(res.code == 0){
                return false;
            }else if(res.code == 1){
                window.location.reload(); 
            }
       }
    });
 }

$("#tm").focus(function(){
	$('#myModal1').modal('show');
});
$(".quanxuan>input").click(function(){
    var val=$('input:checked[name="xz"]:checked').val();
    if(val==null){
        $(".th>span").removeClass('act');
    }else{
    	$(".th>span").addClass('act');
    }
});
$(".th>span").on("click",function(){
    if($(this).hasClass('act')){
        $(this).removeClass('act');
    }
    else{
    	$(this).addClass('act');
    }
});

$("#submit").click(function(){
	 var group_str = '';
	 $(".group_tag .act").each(function(){
	 	 var val = $(this).attr("data-id");
	 	 group_str += val+',';
	 });
	 
	 $("#tm").val(group_str);
	 $("#statis").submit();
	 
});

$(".foot").click(function(){
    var group_tag = $("#tm").val();
    var url = '/sign/sign/detail?group_tag='+group_tag;
	window.open(url);
});

var sign_data = {value:<?=$num?>,name:'已签到'};
var sign_d = {value:<?=$num2?>, name:'未签到'};
var sign_cancel = {value:<?=$num3?>, name:'已取消'};


var myChart1 = echarts.init(document.getElementById('t1'));
option1 = {
    // tooltip : {
    // 	position: [150,-50],
    //     trigger: 'item',
    //     formatter: "{a} <br/>{b} : {c} ({d}%)"
    // },
    color:['#eb9769','#84bd2e','#2F4554'],
    legend: {
        orient: 'vertical',
        left: 'left',
        left: 10,
        itemWidth: 30,
        itemHeight: 15,
        itemGap: 10,
        textStyle: {
        	fontSize: 10
        },
        data: ['已签到','未签到','已取消']
    },
    graphic:{
            type:'text',
            left:'center',
            top:'center',
            style:{
                text:'签到统计',
                textAlign:'center',
                fill:'#ff9000',
				font: 'bolder 14px "Microsoft YaHei", sans-serif'

            }
        },
    calculable : true,
    series : [
        {
            name: '数据分析',
            top: 'top',
            top: 10,
            type: 'pie',
            radius : ['30%', '40%'],
            hoverAnimation: false,
            legendHoverLink: false,
            label: {
            	   normal: {
                    formatter: '{b|{b}：}{c}人',
                    rich: {
                
                        b: {
                            fontSize: 10,
                            lineHeight: 10
                        },
                    }
                }
            },
            itemStyle: {
                emphasis: {
                    shadowBlur: 10,
                    shadowOffsetX: 0,
                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                }
            },
            data:[
                sign_data,
                sign_d,
                sign_cancel
            ]
        }
    ]
};          
myChart1.setOption(option1);

</script>
<?php app\components\JsBlock::end() ?> 